# for循环
for x in range(1, 10):
    for y in range(1, x + 1):
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
    print('')

print('=' * 80)

for x in range(9, 0, -1):
    for y in range(1, x + 1):
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
    print('')

print('=' * 80)

for x in range(1, 10):
    for y in range(9, 0, -1):
        if x < y:
            print(' ' * 8, end='')
        else:
            print('{}*{}={:<4}'.format(x, y, x * y), end='')
    print('')

print('=' * 80)

for x in range(9, 0, -1):
    for y in range(9, 0, -1):
        if x < y:
            print(' ' * 8, end='')
        else:
            print('{}*{}={:<4}'.format(x, y, x * y), end='')
    print('')

print('=' * 80)


# while循环
x = 1
while x <= 9:
    y = 1
    while y <= x:
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
        y += 1
    x += 1
    print('')

print('=' * 80)

x = 9
while x >= 1:
    y = 1
    while y <= x:
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
        y += 1
    x -= 1
    print('')

print('=' * 80)

x = 1
while x <= 9:
    y = 9
    while y >= 1:
        if x < y:
            print(' ' * 8, end='')
        else:
            print('{}*{}={:<4}'.format(x, y, x * y), end='')
        y -= 1
    x += 1
    print('')

print('=' * 80)

x = 9
while x >= 1:
    y = 9
    while y >= 1:
        if x < y:
            print(' ' * 8, end='')
        else:
            print('{}*{}={:<4}'.format(x, y, x * y), end='')
        y -= 1
    x -= 1
    print('')
